package demo;

import java.io.FileInputStream;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.cert.Certificate;

public class KeyStoreExample {
    public static void main(String[] args) throws Exception {
        String keyStorePath = "path/to/keystore.jks";
        String keyStorePassword = "password";
        String alias = "alias";

        KeyStore keyStore = KeyStore.getInstance("JKS");
        FileInputStream fis = new FileInputStream(keyStorePath);
        keyStore.load(fis, keyStorePassword.toCharArray());

        PrivateKey privateKey = (PrivateKey) keyStore.getKey(alias, keyStorePassword.toCharArray());
        Certificate certificate = keyStore.getCertificate(alias);

        // 使用私钥和证书进行加密和解密等操作
    }
}